package com.yangming.springboot.controller;

import com.yangming.springboot.service.UserService;
import com.yangming.springboot.utils.LoginUserUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import com.yangming.springboot.service.PermissionService;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @创建人 ym
 * @创建时间 2021/3/25 0025
 * @描述
 **/
@Controller
@RequestMapping(value = "index")
public class IndexController extends BaseController{

    @Resource
    private UserService userService;

    @Resource
    private PermissionService permissionService;

    public String main(HttpServletRequest request){
        Integer userId = LoginUserUtil.releaseUserIdFromCookie(request);
        List<String> permissions = permissionService.queryUserHasRoleHasModules(userId);
        request.getSession().setAttribute("permissions", permissions);
        return "main";
    }
}
